package cn.oracle;

import cn.oracle.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 * @author wuyuhong
 * @date 2021/03/22 22:22
 **/
@Controller
public class HelloController {
    @Autowired
    HelloService hs;
    @GetMapping("/hello")
    @ResponseBody
    public String hello(){
        System.out.println(hs.hello());
        return "hello java";
    }
    @GetMapping("/hello2")
    public String hello2(){
        return "hello";
    }
    /**返回json*/
    @GetMapping("/hello4")
    @ResponseBody
    public List<User> getNames(){
        List<User>names=new ArrayList<User>();
        for (int i = 0;i< 10 ; i++) {

            names.add(new User("java"+i,new Date()));

        }
        return names;
    }

}
